/* This file is part of PuffinPlot, a program for palaeomagnetic
 * data plotting and analysis. Copyright 2012 Pontus Lurcock.
 *
 * PuffinPlot is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * PuffinPlot is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PuffinPlot.  If not, see <http://www.gnu.org/licenses/>.
 */
/*
 * AboutBox.java
 *
 * Created on 6 November 2008, 14:13
 */

package net.talvi.puffinplot.window;

import net.talvi.puffinplot.*;
import java.awt.Frame;

/**
 * An <q>about this program</q> dialog box giving brief information
 * about PuffinPlot.
 * 
 * @author  pont
 */
public class AboutBox extends javax.swing.JDialog {
    private static final long serialVersionUID = 1L;

    private String gsp(String property) {
        return System.getProperty(property);
    }
    
    private String getContent() {
        final String fmt = 
                "PuffinPlot is a program for showing, exploring, and analysing "
                + "palæomagnetic data. Copyright %s Pontus "
                + "Lurcock (pont at talvi dot net). "
                + "PuffinPlot is free software: you can redistribute it and/or "
                + "modify it under the terms of the GNU General Public License "
                + "as published by the Free Software Foundation, either version "
                + "3 of the License, or (at your option) any later version. "
                + "PuffinPlot is distributed in the hope that it will be useful, "
                + "but WITHOUT ANY WARRANTY; without even the implied warranty "
                + "of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. "
                + "Please see the file LICENCE (supplied with PuffinPlot) "
                + "or go to http://www.gnu.org/licenses/gpl.html "
                + "for details.\n\n"
                + "System information: OS %s %s (%s), Java %s (%s)";
        //String year = PuffinApp.getInstance().getBuildProperty("build.year");
        return String.format(fmt, PuffinApp.getInstance().getVersion().getYearRange(),
                gsp("os.name"), gsp("os.version"),
                gsp("os.arch"), gsp("java.version"), gsp("java.vendor"));
    }
    
    /** Creates new about box.
     * @param owner the frame from which the dialog is displayed
     */
    public AboutBox(Frame owner) {
        super(owner, "About PuffinPlot", true);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jLabel3 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setMinimumSize(new java.awt.Dimension(700, 400));
        setModal(true);
        getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));

        jLabel1.setFont(jLabel1.getFont().deriveFont(jLabel1.getFont().getSize()+8f));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("PuffinPlot");
        jLabel1.setAlignmentX(0.5F);
        jLabel1.setMaximumSize(new java.awt.Dimension(5000, 25));
        jLabel1.setPreferredSize(null);
        getContentPane().add(jLabel1);

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        jTextArea1.setColumns(20);
        jTextArea1.setEditable(false);
        jTextArea1.setLineWrap(true);
        jTextArea1.setRows(5);
        jTextArea1.setText(getContent());
        jTextArea1.setWrapStyleWord(true);
        jTextArea1.setPreferredSize(null);
        jScrollPane1.setViewportView(jTextArea1);

        getContentPane().add(jScrollPane1);

        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("Version: "+PuffinApp.getInstance().getVersion().getVersionString()+". Date: "+PuffinApp.getInstance().getVersion().getDateString());
        jLabel3.setAlignmentX(0.5F);
        jLabel3.setMaximumSize(new java.awt.Dimension(500, 30));
        jLabel3.setMinimumSize(new java.awt.Dimension(45, 30));
        jLabel3.setPreferredSize(new java.awt.Dimension(500, 30));
        getContentPane().add(jLabel3);

        jButton1.setText("Close");
        jButton1.setAlignmentX(0.5F);
        jButton1.setMaximumSize(new java.awt.Dimension(120, 29));
        jButton1.setPreferredSize(new java.awt.Dimension(500, 29));
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    setVisible(false);
}//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration//GEN-END:variables

}
